package com.android.Servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.android.Bean.LinkMainBean;

@SuppressWarnings("serial")
public class LinkManInsertServlet extends HttpServlet {

	/**
	 * 联系人填写
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("gbk");
		LinkMainBean linkMainBean = new LinkMainBean();
		String linkName = request.getParameter("linkName");
		String linkPhone = request.getParameter("linkPhone");
		String linkEmail = request.getParameter("linkEmail");
		PrintWriter pw = response.getWriter();
		try {
			linkMainBean.linkMainInsert(linkName, linkPhone, linkEmail);
			pw.append("true");
			pw.flush();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
			pw.append("false");
			pw.flush();
		} catch (SQLException e) {
			e.printStackTrace();
			pw.append("false");
			pw.flush();
		}
	}

}
